<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2021/5/11
  Time: 8:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>登录</title>

    <link rel="stylesheet" href="/boot/plugins1/layui-v2.6.5/layui/css/layui.css">
    <link rel="stylesheet" href="/boot/plugins1/bootstrap/css/bootstrap.min.css">

    <link href="/boot/css/bootstrap.css" rel="stylesheet">
    <link href="/boot/plugins/revolution/css/settings.css" rel="stylesheet" type="text/css"><!-- REVOLUTION SETTINGS STYLES -->
    <link href="/boot/plugins/revolution/css/layers.css" rel="stylesheet" type="text/css"><!-- REVOLUTION LAYERS STYLES -->
    <link href="/boot/plugins/revolution/css/navigation.css" rel="stylesheet" type="text/css"><!-- REVOLUTION NAVIGATION STYLES -->
    <link href="/boot/css/style.css" rel="stylesheet">
    <link href="/boot/css/responsive.css" rel="stylesheet">
    <link rel="shortcut icon" href="/boot/images/favicon.png" type="image/x-icon">
    <link rel="icon" href="/boot/images/favicon.png" type="image/x-icon">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body>
<div>
    <jsp:include page="../nav.jsp" flush="true"></jsp:include>
    <%--登录--%>
    <form class="form-horizontal" role="form" id="register_from" method="post">
        <div style="margin-left: 200px;margin-bottom:30px;font-size: 20px">记得先登录哦！</div>
        <div class="form-group has-feedback">
            <label for="email" class="col-sm-2 control-label">邮箱号</label>
            <div class="col-md-6">
                <input type="email" class="form-control" id="email" name="email" placeholder="请输入邮箱号"><span class="cc1"></span><br>
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
        </div>
        <div class="form-group has-feedback">
            <label for="code" class="col-sm-2 control-label">验证码</label>
            <div class="col-md-6">
                <input type="text" class="form-control" id="code" name="code" placeholder="请输入邮箱验证码"><span class="cc1"></span><br>
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>


            </div>
            <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" />

        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">


<%--                <div id="button"><input type="button" disabled="disabled" value="按钮"></div>--%>
                <button type="button" class="btn btn-default" id="register_btn11" onclick="sendY()" >登录</button>
            </div>
        </div>
    </form>
    </header>

    <script src="/boot/plugins1/layui-v2.6.5/layui/layui.js"></script>
    <script src="/boot/plugins1/jquery/jquery.min.js"></script>
    <script>

        var wait=10;
        function time(o) {
            if (wait == 0) {
                o.removeAttribute("disabled");
                o.value="免费获取验证码";


                // alert(111);
                wait = 10;
            } else {



                if(wait==9)
                { let email = document.getElementById("email").value;

                    $.post('/boot/send',{"email":email},function (data) {

                if(data.code == "200")
              {
                  alert("发送成功，请耐心等待");
               }

               })
                }

                o.setAttribute("disabled", true);
                o.value="重新发送(" + wait + ")";
                wait--;
                setTimeout(function() {
                        time(o)
                    },
                    1000)
            }
        }
        document.getElementById("btn").onclick=function(){time(this);}






        //        var btn = document.querySelector('btnzz');
//        var time = 60;   // 定义剩下的秒数
//        btn.addEventListener('click', function() {
//
//            let email = document.getElementById("email").value;
//            $.post('/boot/send',{"email":email},function (data) {
//
//                if(data.code == "200")
//                {
//                    alert("发送成功，请耐心等待");
//                }
//
//            })
//
//
//
//
//            btn.disabled = true;
//            var timer = setInterval(function() {
//                if (time == 0) {
//                    // 清除定时器和复原按钮
//                    clearInterval(timer);
//                    btn.disabled = false;
//                    btn.innerHTML = '发送';
//                    time = 60;   // 剩余时间需要从新开始
//                }
//                btn.innerHTML = '还剩下' + time + '秒';
//                time--;
//            }, 1000);
//        });
//
















        //
        // var btn = document.querySelector('btnzz');
        // var time = 60;
        // function send() {
        //
        //     let email = document.getElementById("email").value;
        //
        //
        //   $.post('/boot/send',{"email":email},function (data) {
        //
        //       if(data.code == "200")
        //       {
        //           alert("发送成功，请耐心等待");
        //       }
        //
        //   })
        //     btn.disabled = true;
        //
        //
        //     var timer = setInterval(function() {
        //         if (time == 0) {
        //             // 清除定时器和复原按钮
        //             clearInterval(timer);
        //             btn.disabled = false;
        //             btn.innerHTML = '发送';
        //             time = 60;   // 剩余时间需要从新开始
        //         }
        //         btn.innerHTML = '还剩下' + time + '秒';
        //         time--;
        //     }, 1000);



           //  let email = document.getElementById("email").value;
           //  alert(email);
           // window.location="/boot/user/email?email="+email;




        function sendY() {

            let code = document.getElementById("code").value;

            let email =document.getElementById("email").value;
            // /user/emailYZ
            $.post('/boot/code',{"code":code},function (data) {

                if(data.code == "200")
                {
                    alert("验证码正确，欢迎大大");
                    window.location="/boot/user/index?email="+email;
                }

                if(data.code == "400")
                {

                    alert("非常抱歉大大，验证码已失效，请您重新发送");
                }
                if(data.code == "401")
                {
                    alert("验证码错误，大大是不是眼睛看错了呢");
                }

            })
            //  let email = document.getElementById("email").value;
            //  alert(email);
            // window.location="/boot/user/email?email="+email;
        }

        // function zz(){
        //     window.location = "/boot/registers/register"
        // }
        // $(function(){
        //     $("#register_btn").click(function(){
        //         $(".cc1").html("");
        //         let value = $("#register_from").serialize();
        //         $.post('/boot/user/reg',value,function (data){
        //             console.log(data);
        //             if(data.code=="500")
        //             {
        //                 // alert("数据登录失败");
        //                 let x = data.data;
        //                 console.log(x);
        //                 for(let k in x)
        //                 {
        //                     let uname_input =$("#"+k).next().html("<font color='red'>"+x[k]+"</font>");
        //                 }
        //             }
        //
        //             if(data.code=="200")
        //             {
        //                 // alert("登录成功");
        //                 layui.use('layer', function(){
        //                     var layer = layui.layer;
        //                     layer.msg('登录成功',{icon:6});
        //                 });
        //                 window.location="/boot/user/index"
        //             }
        //             if(data.code=="401")
        //             {
        //                 // alert("密码错误，请重新输入");
        //                 layui.use('layer', function(){
        //                     var layer = layui.layer;
        //                     layer.msg('密码错误，请重新输入',{icon:5});
        //                 });
        //
        //             }
        //             if(data.code=="402")
        //             {
        //                 // alert("用户错误，请重新输入");
        //                 layui.use('layer', function(){
        //                     var layer = layui.layer;
        //                     layer.msg('用户错误，请重新输入',{icon:5});
        //                 });
        //             }
        //         });
        //     });
        // })
    </script>

    <script src="/boot/plugins1/bootstrap/js/bootstrap.min.js"></script>

    <script src="/boot/js/jquery.js"></script>
    <script src="/boot/js/bootstrap.min.js"></script>

    <script src="/boot/plugins/revolution/js/jquery.themepunch.revolution.min.js"></script>
    <script src="/boot/plugins/revolution/js/jquery.themepunch.tools.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.actions.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.carousel.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.kenburn.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.layeranimation.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.migration.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.navigation.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.parallax.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.slideanims.min.js"></script>
    <script src="/boot/plugins/revolution/js/extensions/revolution.extension.video.min.js"></script>
    <script src="/boot/js/main-slider-script.js"></script>

    <script src="/boot/js/jquery-ui.js"></script>
    <script src="/boot/js/jquery.fancybox.pack.js"></script>
    <script src="/boot/js/jquery.fancybox-media.js"></script>
    <script src="/boot/js/owl.js"></script>
    <script src="/boot/js/appear.js"></script>
    <script src="/boot/js/wow.js"></script>
    <script src="/boot/js/main-slider-script.js"></script>
    <script src="/boot/js/script.js"></script>

</div>

</body>
</html>